<template>
    <!-- 工会组织树搜索 -->
    <tree-search
        v-bind="$attrs"
        v-on="$listeners"
        isAll
        ref="treeSearch"
        loadList="getOrgsTree"
        emptyDescription="暂无工会组织信息"
        :replaceFields="{ children: 'children', title: 'unionOrgName', key: 'id' }"
        :api="apiTree"
        @onSelect="onSelect"
        :selectedKeys.sync="selectedKeys"
        :selectOptions.sync="selectOptions"      
        :autoSelect="false"
        :istakeOutHight="istakeOutHight"
    />
</template>

<script>
import TreeSearch from '@/components/businessComponents/TreeSearch' // 树
import { getUnionTreeList, getOrgsTree } from '@/api/union/organizationManagement' // api
import cloneDeep from 'lodash.clonedeep' // 深拷贝
export default {
    components: {
        TreeSearch,
    },
    props: {
     // 是否去掉高度
    istakeOutHight: {
        type: Boolean,
        default: false
    },
        /***
         * 不包含的标签
         */
        // orgQuery: {
        //     type: Object,
        //     default: () => {},
        // },
        // // 是否包含虚拟组织结构
        // containVirtual: {
        //     type: Boolean,
        //     default: false
        // }
        
    },
    computed: {
        // 树节点api
        apiTree() {
            // return { getOrgsTree:()=>getOrgsTree({containVirtual:0}) }
            return {
                getOrgsTree: () => {
                    return getUnionTreeList()
                },
            }
        },
    },
    data() {
        return {
            selectedKeys: {},
            selectOptions: {},
        }
    },
    methods: {
        // 渲染列表
        getList() {
            return this.$refs.treeSearch.getList()
        },
        onSelect(e) {
            this.$emit('onOrgSelect', e)
        },
    },
    watch: {
        selectedKeys(e) {
            this.$emit('update:selectedKeys', e)
        },
        selectOptions(e) {
            this.$emit('update:selectOptions', e)
        },
    },
}
</script>
